package com.jic.manager.impl;

import java.lang.Long;
import java.util.List;

import com.jic.manager.entity.MechannelManagerment;
import com.jic.manager.mapper.MechannelManagermentMapper;
import com.jic.manager.service.MechannelManagermentService;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 渠道管理
 * @author : 
 * @email : 
 * @since : 2020-02-26 09:40:21
 * @version : v1.0.0
 */
@Service
public class MechannelManagermentServiceImpl implements MechannelManagermentService{

    @Resource
    private MechannelManagermentMapper mechannelManagermentMapper;

    @Override
    public long insert(MechannelManagerment mechannelManagerment) {
        long flag = mechannelManagermentMapper.insert(mechannelManagerment);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return mechannelManagermentMapper.delete(id);
    }

    @Override
    public long update(MechannelManagerment mechannelManagerment) {
        return mechannelManagermentMapper.update(mechannelManagerment);
    }

    @Override
    public MechannelManagerment queryByPrimaryKey(Long id){
        return mechannelManagermentMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<MechannelManagerment> query(MechannelManagerment mechannelManagerment){
        return mechannelManagermentMapper.query(mechannelManagerment);
    }

    @Override
    public PageResult<MechannelManagerment> queryPage(MechannelManagerment mechannelManagerment, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<MechannelManagerment> list = mechannelManagermentMapper.queryPage(startIndex, pageQuery.getLimit(), mechannelManagerment);
        long count = mechannelManagermentMapper.queryPageCount(mechannelManagerment);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}